Shader "FrameWork/Day21DepthOnly"
{
    properties
    {
        _BaseMap("Base Map",2d) = "white"{}
        _BaseColor("Base Color",color) = (1,1,1,1)
        [Toggle(_ALPHATEST_ON)]_AlphaToggle("AlphaToggle",float) = 1
        [Toggle(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)]_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_AToggle("SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_AToggle",float) = 1
        [Enum(off,0,front,1,back,2)]_Cull("Cull",float) = 1
        _Cutoff("Cut off",float) = 1
        _AlphaValue("Alpha Value",float) = 1
        _Smoothness("_Smoothness",float) = 1
        [Toggle(_CASTING_PUNCTUAL_LIGHT_SHADOW)]_CASTING_PUNCTUAL_LIGHT_SHADOWoggle("_CASTING_PUNCTUAL_LIGHT_SHADOWToggle",float) = 1
    }
    
    subshader
    {
        Tags
        {
            "RenderPipeline" = "UniversalPipeline"
            "RenderType" = "Opaque"
            "Queue" = "Geometry"
        }
        
        HLSLINCLUDE
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

            CBUFFER_START(UnityPerMaterial)
        
            float4 _BaseMap_ST;
            float4 _BaseColor;
            float _Cull;
            float _Cutoff;
            float _AlphaValue;
            CBUFFER_END
            float _Smoothness;
        ENDHLSL

        pass
        {
            Name "FrameworkDay17"
            Cull[_Cull]
            
            
            Tags
            {
            }
            HLSLPROGRAM

            #pragma shader_feature _ALPHATEST_ON
            #pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A

            
            #pragma vertex UnlitPassVertex
            #pragma fragment UnlitPassFragment
            #pragma multi_compile_instancing
            
            TEXTURE2D(_BaseMap);SAMPLER(sampler_BaseMap);
            
            struct Attributes
            {
                float4 posOS        :POSITION;
                float2 uv           :TEXCOORD0;
                float4 color        :COLOR;
            };

            struct Varyings
            {
                float4 positionCS    :SV_POSITION;
                float2 uv            :TEXCOORD0;
                float4 color         :COLOR;
            };

            Varyings UnlitPassVertex(Attributes IN)
            {
                Varyings OUT = (Varyings)0;
                const VertexPositionInputs position_inputs = GetVertexPositionInputs(IN.posOS.xyz);
                OUT.positionCS = position_inputs.positionCS;
                OUT.uv = TRANSFORM_TEX(IN.uv,_BaseMap);
                OUT.color = IN.color;
                return OUT;
            }

            half4 UnlitPassFragment(Varyings IN) :SV_TARGET
            {

                const half4 baseMap = SAMPLE_TEXTURE2D(_BaseMap,sampler_BaseMap,IN.uv);
                clip(baseMap.a - _Cutoff);
                return baseMap * _BaseColor * IN.color;
            }


            ENDHLSL
        }
        
        Pass
        {
            Name "ShadowCaster"    
            Tags{"LightMode" = "ShadowCaster"}
            ZWrite On
            ZTest LEqual
            ColorMask 0
            Cull [_Cull]
                HLSLPROGRAM
                    #pragma shader_feature _ALPHATEST_ON
                    #pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
                    #pragma multi_compile_instancing

                    #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
                
                    #pragma  vertex ShadowPassVertex
                    #pragma  fragment ShadowPassFragment

                    #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
                    #include  "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
                    #include  "Assets/Day20阴影/CustomShaderPass.hlsl"
            ENDHLSL   
        }
        
        Pass
        {
            Name "DepthOnly"    
            Tags{"LightMode" = "DepthOnly"}
            ZWrite On
            ZTest LEqual
            ColorMask 0
            Cull [_Cull]
            
            HLSLPROGRAM
                    #pragma shader_feature _ALPHATEST_ON
                    #pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
                    #pragma multi_compile_instancing

                    #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
                
                    #pragma  vertex DepthOnlyVertex
                    #pragma  fragment DepthOnlyFragment

                    #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
                    #include  "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
                    #include  "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
            ENDHLSL   
        }
        
        //MSAA
        Pass
        {
            Name "DepthNormals"    
            Tags{"LightMode" = "DepthNormals"}
            ZWrite On
            ZTest LEqual
            ColorMask 0
            //Cull [_Cull]
            
            HLSLPROGRAM
                    #pragma shader_feature_local _NORMAL_MAP
                    #pragma shader_feature _ALPHATEST_ON
                    #pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
                    #pragma multi_compile_instancing

                    #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
                
                    #pragma  vertex DepthNormalsVertex
                    #pragma  fragment DepthNormalsFragment

            

                    #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
                    #include  "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
                    #include  "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
            ENDHLSL   
        }
    }

    //Fallback  "Hidden/Universal Render Pipeline/FallbackError"
}
